//
//  ZZViewUtils.m
//  Qzone
//
//  Created by zhangxy on 2018/5/24.
//  Copyright © 2018年 zhang. All rights reserved.
//

#import "ZZViewUtils.h"

@implementation ZZViewUtils

+(ZTextField *)createZTextField:(NSString *)placeholder{
    ZTextField *backBtn = [[ZTextField alloc] initWithImage:nil padding:5];
    [backBtn setFrame:CGRectMake(20, 0, ScreenWidth-40, 52)];
    [backBtn setBackgroundColor:UIColorFromRGB(TextWhiteColor)];
    backBtn.layer.cornerRadius = 10.0f;
    backBtn.layer.masksToBounds = YES;
    [backBtn setFont:FontSeventeen];
    [backBtn setPlaceholder:placeholder];
    return backBtn;
}

+(ZTextField *)createZTextField:(NSString *)placeholder padding:(CGFloat) p{
    ZTextField *backBtn = [[ZTextField alloc] initWithImage:nil padding:p];
    [backBtn setFrame:CGRectMake(20, 0, ScreenWidth-40, 52)];
    [backBtn setBackgroundColor:UIColorFromRGB(TextWhiteColor)];
    backBtn.layer.cornerRadius = 10.0f;
    backBtn.layer.masksToBounds = YES;
    [backBtn setFont:FontSeventeen];
    [backBtn setPlaceholder:placeholder];
    return backBtn;
}


+(void)cutViewRound:(UIView *) view radius:(CGFloat ) radius byRoundingCorners:(UIRectCorner)corners{
    //设置切哪个直角
    //    UIRectCornerTopLeft     = 1 << 0,  左上角
    //    UIRectCornerTopRight    = 1 << 1,  右上角
    //    UIRectCornerBottomLeft  = 1 << 2,  左下角
    //    UIRectCornerBottomRight = 1 << 3,  右下角
    //    UIRectCornerAllCorners  = ~0UL     全部角
    //得到view的遮罩路径
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(radius,radius)];
    //创建 layer
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = view.bounds;
    //赋值
    maskLayer.path = maskPath.CGPath;
    view.layer.mask = maskLayer;
}

@end
